MAINT Enable low-hanging ruff rules: A, ERA, EXE, FA, FLY, ICN, ISC, LOG, PLE, Q, RSE, SLOT#1412
Open
romanlutz wants to merge 1 commit intoAzure:mainfrom
Open
MAINT Enable low-hanging ruff rules: A, ERA, EXE, FA, FLY, ICN, ISC, LOG, PLE, Q, RSE, SLOT#1412romanlutz wants to merge 1 commit intoAzure:mainfrom
romanlutz wants to merge 1 commit intoAzure:mainfrom
Conversation
…LE, Q, RSE, SLOT Enable 12 additional ruff rule categories with zero or few violations: - A: builtin shadowing (noqa for intentional id/hash/format/dir params) - ERA: commented-out code (noqa for legitimate doc comments) - EXE: executable checks (0 violations) - FA: future annotations (0 violations) - FLY: string formatting (0 violations) - ICN: import conventions (numpy -> np) - ISC: implicit string concatenation (auto-fixed) - LOG: logging best practices (use module logger, not root) - PLE: pylint errors (noqa for bare raise in helper) - Q: quotes (0 violations) - RSE: raise statements (auto-fixed unnecessary parens) - SLOT: slot violations (0 violations) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This maintenance PR enables 12 additional ruff linting rule categories to improve code quality and consistency across the PyRIT codebase. The PR applies a combination of auto-fixes and manual noqa annotations where violations are intentional or necessary.
Changes:
- Enabled 12 new ruff rule categories (A, ERA, EXE, FA, FLY, ICN, ISC, LOG, PLE, Q, RSE, SLOT) in pyproject.toml
- Applied auto-fixes for implicit string concatenation (ISC), raise statement formatting (RSE), and import conventions (ICN: numpy → np)
- Added noqa annotations for intentional builtin shadowing (A: id, hash, format, dir parameters), commented documentation code (ERA), and specific edge cases (PLE0704, LOG014)
- Fixed logging calls to use module-level logger instead of root logger (LOG)
Reviewed changes
Copilot reviewed 42 out of 42 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Added 12 new ruff rule categories to linting configuration and updated ignore patterns |
| tests/unit/target/test_http_target.py | Fixed implicit string concatenation in HTTP request string |
| tests/unit/score/test_self_ask_true_false.py | Added ERA001 noqa for legitimate documentation comment |
| tests/unit/score/test_scorer.py | Added ERA001 noqa for legitimate documentation comments about future implementation |
| tests/unit/models/test_seed.py | Renamed id variable to group_id to avoid shadowing builtin |
| tests/unit/models/test_message_piece.py | Renamed sorted variable to sorted_pieces to avoid shadowing builtin |
| tests/unit/mocks.py | Added A002 noqa for intentional id parameter name |
| tests/unit/exceptions/test_exceptions.py | Removed unnecessary parentheses from raise statements |
| tests/unit/converter/test_transparency_attack_converter.py | Changed numpy import to use standard np alias |
| tests/unit/converter/test_selective_text_converter.py | Added ERA001 noqa for base64 encoding documentation comments |
| tests/unit/converter/test_math_obfuscation_converter.py | Added ERA001 noqa for documentation comment |
| tests/unit/converter/test_image_compression_converter.py | Added A002 noqa for format parameter |
| tests/unit/converter/test_ansi_attack_converter.py | Added ERA001 noqa for documentation comment |
| tests/integration/targets/test_targets_and_secrets.py | Added ERA001 noqa for commented-out test configuration |
| tests/integration/targets/test_openai_responses_gpt5.py | Removed commented-out import statements |
| tests/integration/mocks.py | Added A002/A003 noqa for id parameter and attribute |
| pyrit/ui/rpc_client.py | Removed unnecessary parentheses from raise statement |
| pyrit/ui/rpc.py | Removed unnecessary parentheses from raise statements |
| pyrit/score/scorer_evaluation/scorer_metrics_io.py | Added A002 noqa for hash parameter |
| pyrit/score/scorer.py | Removed unnecessary parentheses from raise statements |
| pyrit/scenario/scenarios/airt/psychosocial_scenario.py | Changed to use module logger instead of root logger |
| pyrit/prompt_target/rpc_client.py | Removed unnecessary parentheses from raise statement |
| pyrit/prompt_target/openai/openai_target.py | Removed unnecessary parentheses from raise statements |
| pyrit/prompt_target/hugging_face/hugging_face_chat_target.py | Removed unnecessary parentheses from raise statement |
| pyrit/prompt_target/crucible_target.py | Removed unnecessary parentheses from raise statement |
| pyrit/prompt_target/azure_ml_chat_target.py | Fixed raise statement and implicit string concatenation |
| pyrit/prompt_target/azure_blob_storage_target.py | Fixed implicit string concatenation in error message |
| pyrit/prompt_converter/transparency_attack_converter.py | Changed numpy import to use standard np alias and updated all references |
| pyrit/prompt_converter/insert_punctuation_converter.py | Renamed loop variable from str to char to avoid shadowing builtin |
| pyrit/prompt_converter/azure_speech_text_to_audio_converter.py | Fixed implicit string concatenation in error messages |
| pyrit/prompt_converter/azure_speech_audio_to_text_converter.py | Fixed implicit string concatenation in error messages |
| pyrit/models/storage_io.py | Fixed implicit string concatenation in error message |
| pyrit/models/seeds/seed.py | Changed to use module logger instead of root logger |
| pyrit/models/score.py | Added A002 noqa for id parameter |
| pyrit/models/scenario_result.py | Added A002 noqa for id parameter |
| pyrit/models/message_piece.py | Added A002 noqa for id parameter |
| pyrit/memory/memory_interface.py | Changed to use module logger instead of root logger |
| pyrit/exceptions/exceptions_helpers.py | Added ERA001 noqa for format documentation comment |
| pyrit/exceptions/exception_classes.py | Added PLE0704 noqa for intentional bare raise |
| pyrit/common/path.py | Added A002 noqa for dir parameter |
| pyrit/backend/middleware/error_handlers.py | Added LOG014 noqa for intentional exc_info usage |
| pyrit/auth/azure_auth.py | Fixed implicit string concatenation in error messages |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enable 12 additional ruff rule categories with zero or few violations:
Description
Tests and Documentation